package com.yun.algorithmproblem.leetcode;

import java.util.ArrayList;
import java.util.List;

public class Leetcode1656 {

    static class OrderedStream {

        String[] str;
        int ptr;

        public OrderedStream(int n) {
            this.str = new String[n + 1];
            this.ptr = 1;
        }

        public List<String> insert(int idKey, String value) {
            List<String> list = new ArrayList<>();
            str[idKey] = value;
            if (idKey == ptr) {
                while (ptr < str.length && str[ptr] != null) {
                    list.add(str[ptr]);
                    ptr++;
                }
            }
            return list;
        }
    }
}
